package com.nhh.v.utils;

import com.google.common.base.Preconditions;

import java.time.Duration;
import java.time.Instant;
import java.util.Date;

/**
 * User: Allen.qin
 * Date: 2018/9/7
 */
public class DateUtils {

    public static Long between(Date startTime, Date endTime) {
        Preconditions.checkArgument(startTime != null, "startTime is null");
        Preconditions.checkArgument(endTime != null, "endTime is null");

        return Duration.between(
                Instant.ofEpochMilli(startTime.getTime()),
                Instant.ofEpochMilli(endTime.getTime())
        ).getSeconds();
    }
}
